﻿using Microsoft.AspNetCore.Mvc;
using SimpleInOutControl.Common;
using SimpleInOutControl.DBModels;
using SimpleInOutControl.Services;

namespace SimpleInOutControl.Controllers
{
    [ApiController]
    [Route("api/[controller]/[action]")]
    public class SystemParameterController: ControllerBase
    {
        SystemParameterService service = new SystemParameterService();

        [HttpGet]
        public ResponseResult<SystemParameter> GetData()
        {
            var result = service.GetData(1);
            return new ResponseResult<SystemParameter>()
            {
                Code = result != null ? 0 : 1,
                Message = result != null ? "成功" : "失败",
                Result = result
            };
        }

        [HttpPut]
        public ResponseResult<bool> UpdateData(SystemParameter dto)
        {
            var result = service.UpdateData(dto);
            return new ResponseResult<bool>()
            {
                Code = result ? 0 : 1,
                Message = result ? "成功" : "失败",
                Result = result
            };
        }
    }
}
